<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //求平均数
        let arr = [10, 40, 60, 90]
        var result = arr.reduce((preVal, curVal) => {
            return preVal + (curVal) / arr.length
        }, 0)
        console.log(result)

        //求索引为奇数的和
        let arr1 = [1, 4, 6, 9]
        var result1 = arr1.reduce((preVal, curVal, curIndex) => {
            /*   if (curIndex % 2 != 0) {
                  return preVal + curVal
              } else {
                  return preVal
              } */

            return curIndex % 2 != 0 ? preVal + curVal : preVal
        }, 0)
        console.log(result1)

        //去重
        /*  let arr2 = [2, 5, 5, 9, 9, 10]
         var result2 = arr2.filter((val, index) => {
             arr2.find
         }) */
    </script>
</body>

</html>